package strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 支付策略工厂
 * 用于管理和获取Spring中的支付策略Bean
 */
@Component
public class PaymentStrategyFactory {
    @Autowired
    private ApplicationContext applicationContext;

    /**
     * 根据策略名称获取支付策略
     * @param strategyName Bean名称
     * @return 支付策略实例
     */
    public PaymentStrategy getStrategy(String strategyName) {
        return applicationContext.getBean(strategyName, PaymentStrategy.class);
    }
}